/*______________________________________________________________________________
________________________________________________________________________________
 
	Hidden Sources of Anti-Muslim Attitudes: Joint Effects of Interactions and Exposure to Immigrants
	Tanaka (2023)
________________________________________________________________________________
______________________________________________________________________________*/


set more off


use "Main_survey.dta", clear


/* Figure A3 */
hist pro_muslim, bin(10) xtitle(Attitudes toward Muslims) ///
	scheme(s1mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) margin(5 5 5 5)) 


/* Table A4 */
reg pro_muslim  i.condition##i.wave i.gender age i.education i.ethnicity ///
	income_house duration_residence dist_relevant_petition, cl(ID) robust 

/* Figure 1 */	
margins i.wave#i.condition
marginsplot, noci ylabel(2(1)5) ytitle(Marginal effects of treatments, size(medsmall)) ///
	title("")
	
bootstrap, reps(500) seed(1234): reg pro_muslim  i.condition##i.wave i.gender age i.education i.ethnicity ///
	income_house duration_residence dist_relevant_petition, cl(ID) robust 

/* Table A7 */	
reg cohesion i.condition##i.wave i.gender age i.education i.ethnicity ///
	income_house duration_residence dist_relevant_petition, cl(ID) robust 



****************************************************************

use "FollowUp_survey.dta", clear


/* Figure 3 */
 
drop if birth_place != 1 /* Nederlands */
drop if ethnicity != 1 /* Wit */

reg friendly arabic headscarf smile, vce(cluster ResponseId)
est sto m1
reg reliable arabic headscarf smile, vce(cluster ResponseId)
est sto m2
reg belonging arabic headscarf smile, vce(cluster ResponseId)
est sto m3
reg admission arabic headscarf smile, vce(cluster ResponseId)
est sto m4

coefplot m1 m2, drop(_cons) xline(0) levels(90) msymbol(C) ytick(,nogrid) ///
	title("The impacts of appearances on personal impression") ///
	ylabel(1 "Arabic" 2 "Headscarf" 3 "Smile") ///
	xscale(r(-0.4 (0.2) 0.6)) xlabel(-0.4 -0.2 0 0.2 0.4 0.6, nogrid) ///
	plotlabels("Friendliness" "Reliability") ///
	scheme(s1manual) graphregion(fcolor(white) ilcolor(white) lcolor(white) margin(5 5 5 5)) 

coefplot m3 m4, drop(_cons) xline(0) levels(90) msymbol(C) ytick(,nogrid) ///
	title("The impacts of appearances on integration issues") ///
	ylabel(1 "Arabic" 2 "Headscarf" 3 "Smile") ///
	xscale(r(-0.4 (0.2) 0.6)) xlabel(-0.4 -0.2 0 0.2 0.4 0.6, nogrid) ///
	plotlabels("Fitting in" "Admission preference") ///
	scheme(s1manual) graphregion(fcolor(white) ilcolor(white) lcolor(white) margin(5 5 5 5)) 


/* Robustness check with a control of the order */
reg friendly arabic headscarf smile i.random_order, vce(cluster ResponseId)
reg reliable arabic headscarf smile i.random_order, vce(cluster ResponseId)
reg belonging arabic headscarf smile i.random_order, vce(cluster ResponseId)
reg admission arabic headscarf smile i.random_order, vce(cluster ResponseId)


/* Robustness check with only first condition */
reg friendly arabic headscarf smile if first_condition_match == 1, vce(cluster ResponseId)
reg reliable arabic headscarf smile  if first_condition_match == 1, vce(cluster ResponseId)
reg belonging arabic headscarf smile  if first_condition_match == 1, vce(cluster ResponseId)
reg admission arabic headscarf smile  if first_condition_match == 1, vce(cluster ResponseId)


****************************************************************

/* Figures A1 and A2 */
clear

local i M0001 V2316 V1180 V1900 V5241 V0013 V0014 V0134 V1915 V5301 ///
 V5303 V5305 V0133 V5103 V0639 V0640 V0642 V2152

import spss `i' using socon2005.sav 


drop if V0134 == 28
keep if V1915 == 1

replace V0639 = . if V0639 == 6
replace V0639 = 6 - V0639

replace V0640 = . if V0640 == 6
replace V0640 = 6 - V0640

replace V0642 = . if V0642 == 6
replace V0642 = 6 - V0642

replace V2152 = . if V2152 == 6
replace V2152 = 6 - V2152

gen threat = (V0639 + V0640 + V0642 + V2152) / 4

hist threat if M0001 == 363,  bin(10) xtitle("Amsterdam") ///
	xscale(r(1 5)) xlabel(1(1)5) ///
	scheme(s1manual) graphregion(fcolor(white) ilcolor(white) lcolor(white) margin(5 5 5 5)) 

	
hist threat if M0001 == 599,  bin(10) xtitle("Rotterdam") ///
	xscale(r(1 5)) xlabel(1(1)5) ///
	scheme(s1manual) graphregion(fcolor(white) ilcolor(white) lcolor(white) margin(5 5 5 5)) 

	
hist threat if M0001 == 518,  bin(10) xtitle("Den Haag") ///
	xscale(r(1 5)) xlabel(1(1)5) ///
	scheme(s1manual) graphregion(fcolor(white) ilcolor(white) lcolor(white) margin(5 5 5 5)) 

	
hist threat if M0001 != 518 | M0001 == 363 | M0001 == 599,  bin(10) xtitle("Rest of the Netherlands") ///
	xscale(r(1 5)) xlabel(1(1)5) ///
	scheme(s1manual) graphregion(fcolor(white) ilcolor(white) lcolor(white) margin(5 5 5 5)) 



****************************************************************


use "Baseline_survey.dta", clear

drop if birthplace != "Nederlands"
drop if ethnicity != "Wit"

reg opposition i.Treatment

collapse (mean) opposition (sd) opp_sd=opposition (count) n=opposition, by(Treatment)

gen hi_opp = opposition + (opp_sd / sqrt(n))
gen lo_opp = opposition - (opp_sd / sqrt(n))
twoway bar opposition Treatment, barwidth(0.5) || ///
	rcap hi_opp lo_opp Treatment || ///
	scatter opposition Treatment,  /// 
	ytitle(Mean opposition answer) ///
	yscale(r(2.5 (0.5) 4)) ylabel(2.5 3 3.5 4, nogrid)  legend(off)  ///
	xlabel(0 "Control" 1 "Short distance" 2 "Long distance") ///
	xtitle("") ///
	scheme(s1manual) graphregion(fcolor(white) ilcolor(white) lcolor(white) margin(5 5 5 5)) 
